<%@page import="dao.LoaiSanPhamDAO"%>
<%@page import="dao.ThuongHieuDAO"%>
<%@page import="dao.SanPhamDAO"%>
<%@page import="dao.LoaiSanPhamDAO"%>
<%@page import="pojo.SanPham"%>
<%@page import="java.util.List"%>
<%@page import="dao.SanPhamDAO"%>
<%@page import="dao.ThuongHieuDAO"%>
<%@page import="pojo.ThuongHieu"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Shoes.dwt" codeOutsideHTMLIsLocked="false" -->
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
    </head>

    <body background="images/Blue_Background.png">
        <%
            int maThuongHieu;
            if (request.getParameter("maThuongHieu") != null) {
                maThuongHieu = Integer.parseInt(request.getParameter("maThuongHieu"));
            } else {
                maThuongHieu = 1;
            }
            String maLoaiSanPham;
            if (request.getParameter("maLoaiSanPham") != null) {
                maLoaiSanPham = request.getParameter("maLoaiSanPham");
            } else {
                maLoaiSanPham = "L001";
            }
            int kieuChon;
            if (request.getParameter("kieuChon") != null) {
                kieuChon = Integer.parseInt(request.getParameter("kieuChon"));
            } else {
                kieuChon = 1;
            }
            String timKiem = request.getParameter("timKiem");
            if (timKiem != null) {
                maThuongHieu = SanPhamDAO.layThongTinSanPham(request.getParameter("tenSanPham")).getThuongHieu().getMaThuongHieu();
            }
            ThuongHieu ThuongHieu = ThuongHieuDAO.layThongTinThuongHieu(maThuongHieu);
            int soLuongSanPhamTrenTrang = 2;
            if (request.getParameter("soLuongSanPhamTrenTrang") != null) {
                soLuongSanPhamTrenTrang = Integer.parseInt(request.getParameter("soLuongSanPhamTrenTrang"));
            }
            int trang = 1;
            if (request.getParameter("Trang") != null) {
                trang = Integer.parseInt(request.getParameter("Trang"));
            }
        %>
        <table width="1034" height="455" align="center" border="1" bordercolor="#FFFFFF">
            <tr align="center">
                <td colspan="5" valign="middle"><img src="images/BannerShoes.gif" width="1024" height="247"/></td>
            </tr>
            <tr>
                <td width="200" align="center"><a href="TrangChu"><img src="images/Button-Trangchu.gif" width="179" height="48"/></a></td>
                <td width="200" align="center"><a href="TrangDangKy"><img src="images/Button-Nam.gif" width="179" height="48"/></a></td>
                <td width="200" align="center"><a href="TrangChu"><img src="images/Button-Nu.gif" width="179" height="48"/></a></td>
                <td width="200" align="center"><a href="TrangChu"><img src="images/Button-Treem.gif" width="179" height="48"/></a></td>
                <td width="200" align="center"><a href="TrangChu"><img src="images/Button-Gioithieu.gif" width="179" height="48"/></a></td>
            </tr>
            <tr align="center">
                <td colspan="5">
                    <p align="right"><font color="#0066FF"><strong>Tìm kiếm theo:</strong></font>
                        <select name="kichCo2" size="1" style="width:15%">
                            <option value="Tất cả" selected="selected">--Chọn thương hiệu--</option>
                            <option>Guicci</option>
                            <option>Puma</option>
                        </select>
                        <select name="kichCo" style="width:15%">
                            <option value="Tất cả" selected="selected">--Chọn loại--</option>
                            <option value="mã danh mục">Tên danh mục</option>
                        </select>
                        <select name="kichCo" style="width:15%">
                            <option value="Tất cả" selected="selected">--Chọn kích cỡ--</option>
                            <option value="mã danh mục">Tên danh mục</option>
                        </select>
                        <select name="kichCo" style="width:15%">
                            <option value="Tất cả" selected="selected">--Chọn giá--</option>
                            <option value="mã danh mục">Tên danh mục</option>
                        </select>
                        <input type="submit" value="Tìm kiếm" name="timKiem">           
                    </p></td>
            </tr>
            <tr>
                <td height="294" align="center">
                    <table width="100%" height="190" cellpadding="5" cellspacing="0" background="images/background.jpg">
                        <tr>
                            <td height="30" align="center" background="images/Bartop.gif"><p><strong><font color="#FFFFFF">THƯƠNG HIỆU</font></strong></p></td>
                        </tr>
                        <% List<ThuongHieu> list = ThuongHieuDAO.layDanhSach();%>
                        <!--BatDauThuongHieu-->
                        <%
                            for (int i = 0; i < list.size(); i++) {
                                ThuongHieu dm = list.get(i);
                        %>
                        <tr>
                            <td>               
                                <a href="DanhSachSanPham.jsp?maThuongHieu=<%=dm.getMaThuongHieu()%>&kieuChon=1"><%=dm.getTenThuongHieu()%></a></td>
                        </tr>  
                        <%}%>
                    </table>
                    <table width="100%" background="images/background.jpg" >
                        <tr>
                            <td colspan="2" height="30" align="center" background="images/Bartop.gif"><p><strong><font color="#FFFFFF">LOẠI SẢN PHẨM</font></strong></p></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/kids_dep.gif"/></td>
                            <td width="137"><a href="DanhSachSanPham.jsp?maLoaiSanPham=L006&kieuChon=2"><font color="#0000FF" >Dép</font></a></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/batavai_Icon.png"/></td>
                            <td width="137"><a href="DanhSachSanPham.jsp?maLoaiSanPham=L001&kieuChon=2"><font color="#0000FF" >Giầy thể thao</font></a></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/men_daytay.gif"/></td>
                            <td width="137"><a  href="DanhSachSanPham.jsp?maLoaiSanPham=L003&kieuChon=2"><font color="#0000FF">Giầy tây</font></a></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/nu_thoitrang.gif"/></td>
                            <td width="137"><a href="DanhSachSanPham.jsp?maLoaiSanPham=L005&kieuChon=2"><font color="#0000FF">Giầy cao gót</font></a></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/men_sandal.gif"/></td>
                            <td width="137"><a href="DanhSachSanPham.jsp?maLoaiSanPham=L004&kieuChon=2"><font color="#0000FF">Sandals</font></a></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/kids_hai.gif"/></td>
                            <td width="137"><a href="DanhSachSanPham.jsp?maLoaiSanPham=L002&kieuChon=2"><font color="#0000FF">Hài</font></a></td>
                        </tr>
                    </table></td>
                <td colspan="4" valign="top"><!-- InstanceBeginEditable name="MainContent" --><table width="100%" border="1" bordercolor="#FFFFFF" cellspacing="0" cellpadding="5">
                        <tr >
                            <td colspan="2" background="images/Bartop.gif"><strong><font color="#FFFFFF">Giay <%=ThuongHieuDAO.layThongTinThuongHieu(maThuongHieu).getTenThuongHieu()%> </font></strong></td>
                        </tr>
                        <tr>
                            <td colspan="2">Trang
                                <%if (kieuChon == 1) {%>
                                <%int soTrang = ThuongHieuDAO.tinhSoLuongTrang(maThuongHieu, soLuongSanPhamTrenTrang);%>
                                <!--BatDauMotTrang-->
                                <%
                   for (int i = 1; i <= soTrang; i++) {%>
                                <a href="DanhSachSanPham.jsp?maThuongHieu=<%=maThuongHieu%>&Trang=<%=i%>&kieuChon=1"><%=i%></a> |
                                <%}
                                  }%> 

                                <%if (kieuChon == 2) {%>
                                <%int soTrang = LoaiSanPhamDAO.tinhsoLuongTheoDoiTuong(maLoaiSanPham, soLuongSanPhamTrenTrang);%>
                                <!--BatDauMotTrang-->
                                <%
                   for (int i = 1; i <= soTrang; i++) {%>
                                <a href="DanhSachSanPham.jsp?maLoaiSanPham=<%=maLoaiSanPham%>&Trang=<%=i%>&kieuChon=2"><%=i%></a> |
                                <%}
                                  }%> 
                            </td>
                            <!--KetThucMotTrang-->

                        </tr>

                        <!--BatDauMotCuonSach-->

                        <tr>
                            <td>   
                                <%
                                    if (kieuChon == 1) {
                                        List<SanPham> dsSanPham = SanPhamDAO.layDanhSachSanPham(maThuongHieu, soLuongSanPhamTrenTrang, trang);
                                        for (int i = 0; i < dsSanPham.size(); i++) {
                                            SanPham s = dsSanPham.get(i);

                                %>
                                <table width="100%" border="0" cellspacing="0" cellpadding="5">
                                    <tr>
                                        <td width="30%" rowspan="6" valign="top"><a href="ChiTietSach.jsp?maSach=01"><img src="images/GiayTheThao.png" alt="#" width="250" height="171" border="0" /></a></td>
                                        <td><a href="ChiTietSanPham.jsp?MaSanPham=SP001"><%=s.getMaSanPham()%></a></td>
                                    </tr>
                                    <tr>
                                        <td>Xuất xứ: <strong><%=s.getXuatXu()%></strong></td>
                                    </tr>
                                    <tr>
                                        <td>Giá bán: <strong><font color="#FF0000"><%=s.getGiaBan()%></font></strong>VNĐ</td>
                                    </tr>
                                    <tr>
                                        <td valign="top">Số lượng online:<strong><font color="#FF0000"> <%=s.getSoLuong()%> </font></strong> đôi</td>
                                    </tr>
                                    <tr>
                                        <td valign="top"><a href="ChiTietSanPham.jsp?MaSanPham=<%=s.getMaSanPham()%>"><img src="images/Button-chitiet.jpg" width="80" border="0" /></a></td>
                                    </tr>
                                    <tr>
                                        <td valign="top"><a href="GioHang.jsp?action=DatMua&maSanPham=<%=s.getMaSanPham()%>"><img src="images/Button-datmua.jpg" border="0" width="80"/></a></td>
                                    </tr>
                                </table>
                                <%}%>
                                <%}%> 
                                <%
                                    if (kieuChon == 2) {
                                        List<SanPham> dsSanPham = SanPhamDAO.layDanhSachSanPhamTheoLoai(maLoaiSanPham, soLuongSanPhamTrenTrang, trang);
                                        for (int i = 0; i < dsSanPham.size(); i++) {
                                            SanPham s = dsSanPham.get(i);

                                %>
                                <table width="100%" border="0" cellspacing="0" cellpadding="5">
                                    <tr>
                                        <td width="30%" rowspan="6" valign="top"><a href="ChiTietSach.jsp?maSach=01"><img src="images/GiayTheThao.png" alt="#" width="250" height="171" border="0" /></a></td>
                                        <td><a href="ChiTietSanPham.jsp?MaSanPham=SP001"><%=s.getMaSanPham()%></a></td>
                                    </tr>
                                    <tr>
                                        <td>Xuất xứ: <strong><%=s.getXuatXu()%></strong></td>
                                    </tr>
                                    <tr>
                                        <td>Giá bán: <strong><font color="#FF0000"><%=s.getGiaBan()%></font></strong>VNĐ</td>
                                    </tr>
                                    <tr>
                                        <td valign="top">Số lượng online:<strong><font color="#FF0000"> <%=s.getSoLuong()%> </font></strong> đôi</td>
                                    </tr>
                                    <tr>
                                        <td valign="top"><a href="ChiTietSanPham.jsp?MaSanPham=<%=s.getMaSanPham()%>"><img src="images/Button-chitiet.jpg" width="80" border="0" /></a></td>
                                    </tr>
                                    <tr>
                                        <td valign="top"><a href="GioHang.jsp?action=DatMua&maSanPham=<%=s.getMaSanPham()%>"><img src="images/Button-datmua.jpg" border="0" width="80"/></a></td>
                                    </tr>
                                </table>
                                <%}
                             }%> 
                            </td>           
                        </tr>

                        <!--KetThucCuonSach-->

                    </table><!-- InstanceEndEditable --></td>
            </tr>
            <tr align="center">
                <td colspan="5" background="images/Bartop.gif">&nbsp;</td>
            </tr>
            <tr align="center">
                <td colspan="5">
                    <p align="right"><a><font color="#0000FF"><strong>Đăng nhập &nbsp;&nbsp;  </strong></font></a> <a><font color="#0000FF"><strong>Đăng ký&nbsp;</strong></font></a></p></td>
            </tr>
            <tr align="center">
                <td colspan="5"><strong>@ 2012 Le Khanh Nhac </strong> <a href="#" target="_blank">Terms &amp; Privacy</a></td>
            </tr>
        </table>
    </body>
    <!-- InstanceEnd --></html>
